Passed
Push — master ( ea6aae...edf917 )
by Endre
53s queued 11s
created

StorageAdapter.onChange   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
crap 1
1
import {IObserverAdapter, IOnChangeCallback} from '@enbock/state-value-observer/Observer';
2
3 2
export default class StorageAdapter<T> implements IObserverAdapter<T> {
4
  protected baseAdapter: IObserverAdapter<T>;
5
  protected onChangeCallback: IOnChangeCallback<T>;
6
7
  constructor(baseAdapter: IObserverAdapter<T>, onChangeCallback: IOnChangeCallback<T>) {
8 2
    this.baseAdapter = baseAdapter;
9 2
    this.onChangeCallback = onChangeCallback;
10
  }
11
12 2
  onChange(newValue: T): void {
13 2
    this.onChangeCallback(newValue);
14 2
    this.baseAdapter.onChange(newValue);
15
  }
16
}
17